package com.chx.rpc01;

import com.chx.dto.User;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class Client {

    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("localhost",8080);
        //ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DataOutputStream dos=new DataOutputStream(socket.getOutputStream());
        dos.writeInt(1);
        dos.flush();

        DataInputStream dis=new DataInputStream(socket.getInputStream());
        User user=new User(dis.readInt(),dis.readUTF());
        System.out.println(user);

        dis.close();
        dos.close();
        socket.close();
    }
}
